
import java.awt.Color;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Dorothy
 */
public class SearchSuite extends javax.swing.JFrame {

    /**
     * Declaring variables in the class and creating the table columns
     */
    
    
     Connection conn = null;
        PreparedStatement p = null;
        ResultSet rs = null;
        
        String[] colname = { "sNum", "type", "sPrice", "availability"};
        String [] searchOptions = {"sNum", "type", "sPrice",  "availability"};
        DefaultTableModel dm = new DefaultTableModel(colname, 5);
        
    /**
     * Creates new form SearchSuite
     */
        public SearchSuite() {
        initComponents();

        setVisible(true);
        getContentPane().setBackground(Color.BLACK);
        suiteTable.setEnabled(false);
      
        suiteTable.setModel(dm);
        dm.setColumnIdentifiers(colname);
        msgLabel.setText("Select either  sNum,type, sPrice or availability");
        
        
        for(int i=0; i<searchOptions.length;i++){       //add items to combobox
           searchCombo.addItem(searchOptions[i]);       
        }
        
       // System.out.println("SQL Test");

        try {
            
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            conn = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/comfort_hub?user=root&password=root");
        } catch (Exception e) {
            System.out.println(e);
            System.exit(0);
        }

        System.out.println("Connection established");
    
    }
    

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        suiteTable = new javax.swing.JTable();
        searchCombo = new javax.swing.JComboBox();
        CLOSEButton = new javax.swing.JButton();
        SearchSuitetText = new javax.swing.JTextField();
        msgLabel = new javax.swing.JLabel();
        SearchButtonSuite = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        SEARCHButtonReservation = new javax.swing.JButton();
        SEARCHButtonEmployee = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        suiteTable.setBackground(new java.awt.Color(153, 102, 0));
        suiteTable.setModel(dm);
        jScrollPane1.setViewportView(suiteTable);

        searchCombo.setBackground(new java.awt.Color(153, 102, 0));
        searchCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchComboActionPerformed(evt);
            }
        });

        CLOSEButton.setBackground(new java.awt.Color(153, 102, 0));
        CLOSEButton.setForeground(new java.awt.Color(0, 51, 51));
        CLOSEButton.setText("CLOSE");
        CLOSEButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CLOSEButtonActionPerformed(evt);
            }
        });

        SearchSuitetText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchSuitetTextActionPerformed(evt);
            }
        });

        SearchButtonSuite.setBackground(new java.awt.Color(153, 102, 0));
        SearchButtonSuite.setText("SEARCH");
        SearchButtonSuite.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchButtonSuiteActionPerformed(evt);
            }
        });

        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Suites");

        SEARCHButtonReservation.setBackground(new java.awt.Color(153, 102, 0));
        SEARCHButtonReservation.setText("SEARCH RESERVATIONS");
        SEARCHButtonReservation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SEARCHButtonReservationActionPerformed(evt);
            }
        });

        SEARCHButtonEmployee.setBackground(new java.awt.Color(153, 102, 0));
        SEARCHButtonEmployee.setText("SEARCH EMPLOYEES");
        SEARCHButtonEmployee.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SEARCHButtonEmployeeActionPerformed(evt);
            }
        });

        jLabel2.setIcon(new javax.swing.ImageIcon("C:\\Users\\Dorothy\\Documents\\NetBeansProjects\\comfort-hub\\hot.jpg")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(62, 62, 62)
                        .addComponent(msgLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(36, 36, 36)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 535, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(115, 115, 115)
                                .addComponent(SEARCHButtonReservation)
                                .addGap(68, 68, 68)
                                .addComponent(SEARCHButtonEmployee, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(0, 26, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(93, 93, 93)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(searchCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(35, 35, 35)
                        .addComponent(SearchSuitetText, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(45, 45, 45)
                        .addComponent(SearchButtonSuite))
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 284, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(CLOSEButton)
                .addGap(259, 259, 259))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(searchCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(SearchSuitetText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(SearchButtonSuite))
                .addGap(25, 25, 25)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(SEARCHButtonReservation)
                    .addComponent(SEARCHButtonEmployee))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(msgLabel)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(CLOSEButton)
                .addContainerGap(25, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void searchComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchComboActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_searchComboActionPerformed

    private void CLOSEButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CLOSEButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_CLOSEButtonActionPerformed

    private void SearchSuitetTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchSuitetTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_SearchSuitetTextActionPerformed

    private void SearchButtonSuiteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchButtonSuiteActionPerformed
        // TODO add your handling code here:

    }//GEN-LAST:event_SearchButtonSuiteActionPerformed

    private void SEARCHButtonReservationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SEARCHButtonReservationActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_SEARCHButtonReservationActionPerformed

    private void SEARCHButtonEmployeeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SEARCHButtonEmployeeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_SEARCHButtonEmployeeActionPerformed
/**
 * 
 * @return CLOSEButton,SEARCHButtonEmployee,SEARCHButtonReservation,SearchButtonSuite
 * SearchSuitetText,searchCombo,msgLabel,suiteTable,dm
 */
   public JButton getCLOSEButton(){
       return  CLOSEButton;
    }
   
   
   
    public JButton getSEARCHButtonEmployee(){
       return  SEARCHButtonEmployee;
    }
    
    
  public JButton getSEARCHButtonReservation(){
       return  SEARCHButtonReservation;
    }   
    
    
     public JButton getSearchButtonSuite(){
       return  SearchButtonSuite;
    }  
    
    
      
public JTextField getSearchSuiteText(){
       return  SearchSuitetText;
    } 
    

public JComboBox getsearchCombo(){
       return  searchCombo;
    }


public JLabel getmsgLabel(){
       return  msgLabel;
    }



public JTable getSuiteTable(){
       return  suiteTable;
    }


public DefaultTableModel getModel(){
return dm;
}
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(SearchSuite.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(SearchSuite.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(SearchSuite.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(SearchSuite.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new SearchSuite().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CLOSEButton;
    private javax.swing.JButton SEARCHButtonEmployee;
    private javax.swing.JButton SEARCHButtonReservation;
    private javax.swing.JButton SearchButtonSuite;
    private javax.swing.JTextField SearchSuitetText;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel msgLabel;
    private javax.swing.JComboBox searchCombo;
    private javax.swing.JTable suiteTable;
    // End of variables declaration//GEN-END:variables
}
